﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="scripts/Soapi.js" type="text/javascript"></script>


    <script type="text/javascript">


        function run() {

            // your app's api key, if you have one
            var apiKey = 'qgAq_KfDu0KYzlNG-qaTuw';

            // the target site. You may simply specify a string constant
            var targetSite = 'api.stackoverflow.com';



            // the only type in Soapi.JS that you will instantiate is
            // a RouteFactory. 
            var factory = new Soapi.RouteFactory(targetSite, apiKey);

            var route = factory.ErrorsById().applyParameters({
                id: 500
            });

            route.getResponse(
            // data will be the response type
            function success(data) {
                alert("failed to get error- should not see this anyway");
            },
            // data will be the error
            function error(data) {
                alert(route._lastUrl + "\r\n\r\ncode: " + data.code + "\r\nmessage: " + data.message);
            },
            // specify timeout if the default 3000 is not acceptable
            2000);
        };
    </script>

</head>
<body onload="run()">
</body>
</html>
